<?php

namespace App\Modules\Core\Http\Middleware;


use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Contracts\Auth\Factory as Auth;

class Authenticate extends Middleware
{

    /**
     * The authentication guard factory instance.
     *
     * @var \Illuminate\Contracts\Auth\Factory
     */
    protected $auth;

    /**
     * Create a new middleware instance.
     *
     * @param \Illuminate\Contracts\Auth\Factory $auth
     * @return void
     */
//    public function __construct(Auth $auth)
//    {
//        parent::__construct($auth);
//        $this->auth = $auth;
//    }

//    public function handle($request, Closure $next, $guard = '')
//    {
//        if ($this->auth->guard($guard)->guest()) {
//            return response('Unauthorized.', 401);
//        }

//        return $next($request);
//    }

    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param \Illuminate\Http\Request $request
     * @return string
     */
    protected function redirectTo($request)
    {
        if (!$request->expectsJson()) {
            return route('admin.user.login');
        }
    }
}
